function initExt(viewModel, requestUtils) {
    // 在这里写业务逻辑

    let applyOrdersGridModel = viewModel.getGridModel("zyhy_apply_ordersList")
    applyOrdersGridModel.on("afterCellValueChange", function (event) {
        //rowIndex:'行号', cellName: '列名', value: '新值', oldValue: '旧值'
        let {rowIndex, cellName, value, oldValue, childrenField} = event;

        // 选项目 自动带出 对应经费卡 当前的 占用
        if (cellName == "project_name") {

            let orgId = viewModel.get("org").getValue()
            let project = value.id
            if (!project || !orgId) {
                applyOrdersGridModel.setCellValue(rowIndex, "actual_occupy", null)
                return
            }
            let {result, err} = requestUtils.doPostSync("/expenseCard/getExpenseCardByProject", {
                "orgId": orgId,
                "project": project
            })
            debugger
            if (err) {
                cb.utils.alert(`查询项目实际可用余额和预估占用失败，原因：${err}`, "error")
                return
            }
            if (!result) {
                result = {actual_occupy: null}
                cb.utils.alert("查询项目实际可用余额和预估占用失败，该项目在当前需求组织下，无对应经费卡", "error")
            }

            applyOrdersGridModel.setCellValue(rowIndex, "actual_occupy", result.actual_occupy)


        }

        if (cellName == "pur_qty" || cellName == "price") {
            let pur_qty = applyOrdersGridModel.getCellValue(rowIndex, "pur_qty") || 0
            let price = applyOrdersGridModel.getCellValue(rowIndex, "price") || 0
            let money = pur_qty * price
            applyOrdersGridModel.setCellValue(rowIndex, "money", money)
        }

    });
};


cb.define(process.env.__DOMAINKEY__, ['common/requestUtils.js'], function (requestUtils) {
    let vm = {
        doAction: function (name, viewModel) {
            if (this[name])
                this[name](viewModel);
        },
        init: function (viewModel) {
            initExt(viewModel, requestUtils);
        }
    }
    try {
        module.exports = vm;
    } catch (error) {
        console.log(error);
    }
    return vm;
});